package com.fll.codeworld.es.config;

import org.apache.http.HttpHost;
import org.elasticsearch.client.*;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @author fll
 * @description
 * @date 2022/1/28 11:48
 */
@Configuration
public class ElasticSearchConfig {
    /**
     * 创建单例模式的RequestOptions，使得所有请求共用
     */
    @Bean
    public RestHighLevelClient client() {
        RestClientBuilder builder=RestClient.builder(new HttpHost("127.0.0.1", 9200, "http"));
        RestHighLevelClient client = new RestHighLevelClient(builder);
        return client;
    }
}
